package easy;

public class Solution_1736 {

    public String maximumTime(String time) {
        char[] chars = new char[5];
        if (time.charAt(0) == '?') {
            if (time.charAt(1) == '?' || (time.charAt(1) - '0') < 4) {
                chars[0] = '2';
            } else {
                chars[0] = '1';
            }
        } else {
            chars[0] = time.charAt(0);
        }
        if (time.charAt(1) == '?') {
            if (chars[0] == '2') {
                chars[1] = '3';
            } else {
                chars[1] = '9';
            }
        } else {
            chars[1] = time.charAt(1);
        }
        chars[2] = ':';
        if (time.charAt(3) == '?') {
            chars[3] = '5';
        } else {
            chars[3] = time.charAt(3);
        }
        if (time.charAt(4) == '?') {
            chars[4] = '9';
        } else {
            chars[4] = time.charAt(4);
        }
        return new String(chars);
    }
}
